{% extends "layout.html" %}
{% block body %}

{% block header %}
<style>
  body {
    margin: 0;
    font-family: Arial, sans-serif;
  }
</style>
{% endblock %}

<div class="discover">
  <h2>{{title}}</h2>

  <div>
    <h3>Calibre-Web Automated - Server Stats</h3>
    <div class="cwa_stats_container">
      <div class="cwa_stats_section">
        <div class="cwa_stats_header">Total Books</div>
        <div class="cwa_stats_value">{{cwa_stats["total_books"]}}</div>
      </div>
      <div class="cwa_stats_section">
        <div class="cwa_stats_header">Books Enforced</div>
        <div class="cwa_stats_value">{{cwa_stats["cwa_enforcement"]}}</div>
      </div>
      <div class="cwa_stats_section">
        <div class="cwa_stats_header">Books Converted</div>
        <div class="cwa_stats_value">{{cwa_stats["cwa_conversions"]}}</div>
      </div>
      <div class="cwa_stats_section">
        <div class="cwa_stats_header">Books Fixed</div>
        <div class="cwa_stats_value">{{cwa_stats["epub_fixes"]}}</div>
      </div>
    </div>
  </div>

  <hr style="width: 85%;text-align: center;margin-bottom: 36px;border-width: medium;border-color: #96a2a9;border-radius: 8px;">

    <div>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h3 style="margin: 0;">Calibre-Web Automated Conversion History</h3>
        <a class="btn btn-default stats_see_more_btn" href="{{ url_for('cwa_stats.show_full_conversions') }}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_conversion %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_conversions|reverse %}
        <tr>
          {% for cell in row %}
          <td>{{ cell }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
    </div>

    <div>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h3 style="margin: 0;">Calibre-Web Automated Import History</h3>
        <a class="btn btn-default stats_see_more_btn" href="{{ url_for('cwa_stats.show_full_imports') }}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_import %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_imports|reverse %}
        <tr>
          {% for cell in row %}
          <td>{{ cell }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
    </div>

    <div>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h3 style="margin: 0;">Calibre-Web Automated EPUB Fixer History</h3>
        <a class="btn btn-default stats_see_more_btn" href="{{ url_for('cwa_stats.show_full_epub_fixer') }}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_epub_fixer %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_epub_fixer|reverse %}
        <tr>
          {% for cell in row %}
          <td>{{ cell }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h4 style="margin: 0;"><i>EPUB Fixer History with Paths & Fixes</i></h4>
        <a class="btn btn-default stats_see_more_btn" href="{{ url_for('cwa_stats.show_full_epub_fixer_with_paths_fixes') }}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_epub_fixer_with_fixes %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_epub_fixer_with_fixes|reverse %}
        <tr>
          {% for cell in row %}
          <td>
            <div style="max-height: 20rem; overflow-y: auto;">{{ cell | replace("\n", "<br>") | safe }}</div>
          </td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
    </div>

    <div>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h3 style="margin: 0;">Calibre-Web Automated Enforcement History</h3>
        <a class="btn btn-default stats_see_more_btn" href="{{url_for('cwa_stats.show_full_enforcement')}}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_enforcement %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_enforcement|reverse %}
        <tr>
          {% for cell in row %}
          <td>{{ cell }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <h4 style="margin: 0;"><i>Enforcement History with Paths</i></h4>
        <a class="btn btn-default stats_see_more_btn" href="{{ url_for('cwa_stats.show_full_enforcement_path') }}">{{_('Click to See More')}}</a>
      </div>
      <br>
      <table class="table table-striped">
        <tr>
          {% for header in headers_enforcement_with_paths %}
          <th>{{ header }}</th>
          {% endfor %}
        </tr>
        {% for row in data_enforcement_with_paths|reverse %}
        <tr>
          {% for cell in row %}
          <td>{{ cell }}</td>
          {% endfor %}
        </tr>
        {% endfor %}
      </table>
    </div>

</div>
{% endblock %}